home *** CD-ROM | disk | FTP | other *** search
- // base1.cpp: Shows the bases of integers
- #include <iostreams.h>
-
- main()
- {
- int x, y, z;
-
- cout << "Enter three ints: ";
- cin >> x >> y >> z;
- cout << x << ',' << y << ',' << z << endl;
-
- // Print in different bases
- cout << x << ',';
- cout.setf(ios::oct,ios::basefield);
- cout << y << ',';
- cout.setf(ios::hex,ios::basefield);
- cout << z << endl;
-
- // Show the base prefix
- cout.setf(ios::showbase);
- cout << x << ',';
- cout.setf(ios::oct,ios::basefield);
- cout << y << ',';
- cout.setf(ios::hex,ios::basefield);
- cout << z << endl;
- return 0;
- }
-
- // Sample Execution
- // Enter three ints: 10 010 0x10
- // 10,8,16
- // 10,10,10
- // 0xa,010,0x10
-
-